package m.common.model;

import com.alibaba.fastjson.JSONObject;
import m.common.model.util.ModelUtil;
import m.system.exception.MException;
import m.system.util.JSONMessage;
import m.system.util.ObjectUtil;

import java.io.Serializable;

/**
 * 模型基础类. 所有表的主键都是oid
 * @author Administrator
 *
 */
public class Model implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@KeyFieldMeta(name="oid")
	private String oid;

	public String getOid() {
		return oid;
	}

	public void setOid(String oid) {
		this.oid = oid;
	}

	public JSONMessage toJson(){
        try {
            return ModelUtil.toJSONMessage(this);
        } catch (MException e) {
            return new JSONMessage(((JSONObject)JSONObject.toJSON(this)).getInnerMap());
        }
    }
}
